package com.junit.controller;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.util.AopTestUtils;
import org.springframework.test.util.ReflectionTestUtils;

import javax.servlet.Servlet;
import javax.xml.bind.JAXBException;

import static org.mockito.Mockito.mock;

/**
 * @author CKC
 * @DateTime 2021/11/15 20:41
 */
@SpringBootTest(classes = HelloController.class)
public class Demo1 {

    @BeforeEach
    @DisplayName("beforeEach_Test")
    public void beforeTest() {
        System.out.println("beforeEachTest");
    }

    @AfterEach
    @DisplayName("afterEach_Test")
    public void afterTest() {
        System.out.println("afterEachTest");
    }


    @Test
    @DisplayName("demo1")
    public void demo_1(@Autowired HelloController hello) {
        Object targetObject = AopTestUtils.getTargetObject(hello);
//        @EnableAspectJAutoProxy
        ReflectionTestUtils.invokeMethod(targetObject, "dfdf");

        System.out.println(hello.helloWorld("ckc"));
    }

    /**
     *
     */
    public void sjdhj(){
    }


}
